﻿#include "mTestLabel.h"
#include <QDebug>
#include "stable.h"




mTestLabel::mTestLabel(QWidget *parent)
    : QLabel(parent)
{
    setMouseTracking(true);
}



void mTestLabel::enterEvent(QEvent *event)
{
    setText(tr("choosed label"));
}



void mTestLabel::leaveEvent(QEvent *event)
{
    setText(tr("not choosed label"));
}



void mTestLabel::mousePressEvent(QMouseEvent *event)
{
    QString str = tr("clike left button");

    if(event->button() == Qt::LeftButton)
    {
        setText(str);
    }
}



void mTestLabel::mouseReleaseEvent(QMouseEvent *event)
{
    setText(tr("release left button"));
}



void mTestLabel::mouseMoveEvent(QMouseEvent *event)
{
    QString str = QString(tr("Control") + "[x=%1,y=%2]" +tr("Screen") +"[x=%3,y=%4]")
            .arg(event->x()).arg(event->y()).arg(event->globalX()).arg(event->globalY());

    setText(str);
}


void mTestLabel::wheelEvent(QWheelEvent *event)
{
    int   nTempFontSize  = font().pointSize() ;
    if(event->delta() > 0 )
    {
        setFont(QFont("新宋体",(nTempFontSize + 1 >= 20) ? 20 : (nTempFontSize + 1)));
    }
    else
    {
        setFont(QFont("新宋体",(nTempFontSize - 1 <= 12) ? 12 : (nTempFontSize - 1)));
    }
}
